package com.dgut.edu.cn.design.mode.filterchain.filter;

import com.dgut.edu.cn.design.mode.filterchain.dto.PriceCompareResult;
import com.dgut.edu.cn.design.mode.filterchain.dto.RuleFilterResVo;
import org.springframework.stereotype.Service;

/**
 * @description:
 * @author: hongbin.zheng
 * @create: 2023-08-10 18:49
 **/
@Service
public class MidRuleFilter implements RuleFilter<PriceCompareResult> {

	@Override
	public RuleFilterResVo doFilter(PriceCompareResult priceCompareResult) throws Exception{
		if (priceCompareResult.getMerchandiseNo() % 10 == 0) {
			// 如果mid 被 10整除，则过滤
			return RuleFilterResVo.fail("若mid 被 10整除，则过滤，mid = " + priceCompareResult.getMerchandiseNo(), name());
		}
		return RuleFilterResVo.ok(name());
	}

	@Override
	public String name() {
		return "midRuleFilter";
	}
}
